﻿using System;
using System.Collections.Generic;
using System.Text;
using DAL.DateSet.PaintColorMappingTableAdapters;
using DAL.DateSet;
using DAL;
namespace BLL.Wrapper
{
    public class PaintColorMappingWrapper : PaintColorMappingTableAdapter
    {
        public PaintColorMapping.PaintColorMappingDataTable getall()
        {
            return GetData();
        }

        public void addARecord(PaintColorMapping.PaintColorMappingRow row)
        {
            Insert(row.paintColorID, row.goodsID, row.paintUnitPrice, row.priceCreator, row.priceCreateDate);
        }

        public void deleteByID(int id)
        {
            string sql = "delete from PaintColorMapping where mappingID = " + id.ToString();
            HouseDiyHelper helper = HouseDiyHelper.GetInstance();
            helper.initOle();
            helper.delete(sql);
        }

        public void updateARecord(PaintColorMapping.PaintColorMappingRow row)
        {
            PaintColorMapping.PaintColorMappingDataTable table = GetData();
            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (Convert.ToInt32(table.Rows[i]["mappingID"]) == row.mappingID)
                {
                    table.Rows[i]["paintColorID"] = row.paintColorID;
                    table.Rows[i]["goodsID"] = row.goodsID;
                    table.Rows[i]["paintUnitPrice"] = row.paintUnitPrice;
                    table.Rows[i]["priceCreator"] = row.priceCreator;
                    table.Rows[i]["priceCreateDate"] = row.priceCreateDate;
                    break;
                }
            }
            Update(table);
        }
    }
}
